Skip to content

Add Wikipedia Library survey for active TWL users#1497

Merged
katydidnot merged 5 commits intomasterfrom
Jsn.sherman/T409420
Dec 5, 2025
Merged

Add Wikipedia Library survey for active TWL users#1497
katydidnot merged 5 commits intomasterfrom
Jsn.sherman/T409420

Conversation

@jsnshrmn
Copy link
Member

@jsnshrmn jsnshrmn commented Dec 3, 2025

Bug: T409420

Description

Add user survey email command, including:

  • management command
  • email task
  • email templates

Rationale

See parent task, T402650

Phabricator Ticket

T409420

How Has This Been Tested?

Added unit test, and did manual local testing

Local testing:
ran SQL queries against local data to spot check account age logic against raw data. Example:

select auth_user.email, DateDiff(auth_user.last_login,users_editor.wp_registered) as login_age
from users_editor join auth_user on users_editor.user_id=auth_user.id
where DateDiff(auth_user.last_login,users_editor.wp_registered) > 182
and auth_user.email <> ""
and auth_user.is_staff = 0
and auth_user.is_active = 1
and auth_user.is_superuser = 0
and users_editor.wp_enough_edits = 1
and users_editor.wp_not_blocked = 1;

(Note that this is a slightly loose selection)

edited survey_active_users to print equivalent info instead of sending message and updating accounts. Example:

print("| {email}|{login_age} |".format(email=user.email.ljust(64),login_age=str(user.last_login_age.days).rjust(8)))

ran command, eg python manage.py survey_active_users 000001 en fr de ja ru es
and viewed output, spot checked info against db query results

Screenshots of your changes (if appropriate):

N/A

Types of changes

What types of changes does your code introduce? Add an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Minor change (fix a typo, add a translation tag, add section to README, etc.)

Check wp account age at last login rather than current account age

Bug: T409420
- test eligible and ineligible users
- wp account age at last login should be gte 182 days
- remove migration from commit (will be committed by CI)

Bug: T409420
@jsnshrmn jsnshrmn force-pushed the Jsn.sherman/T409420 branch from 34f0abd to 4923d30 Compare December 5, 2025 18:33
@jsnshrmn jsnshrmn changed the title WIP: Add Wikipedia Library survey for active TWL users Add Wikipedia Library survey for active TWL users Dec 5, 2025
"--staff_test" arg inverts is_staff to only email staff users who are
  otherwise eligible

Bug: T409420
Copy link
Contributor

@DHardy-WMF DHardy-WMF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one minor formatting issue to fix and I'll approve.

)

def handle(self, *args, **options):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Black is complaining about this empty line. After I removed it locally, all the unit tests were successful.

Copy link
Contributor

@katydidnot katydidnot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, and works as expected in my testing locally.

It does look like there's a minor formatting error to fix before I can merge.

ran `docker compose exec twlight /venv/bin/black -t py311 /app/TWLight`

Bug: T409420
@jsnshrmn
Copy link
Member Author

jsnshrmn commented Dec 5, 2025

turns out different versions of black can have different results for the same target. My host version was different, so I ran docker compose exec twlight /venv/bin/black -t py311 /app/TWLight to get the same thing that should be running in ci

@katydidnot katydidnot merged commit 7b249a0 into master Dec 5, 2025
5 checks passed
@jsnshrmn jsnshrmn deleted the Jsn.sherman/T409420 branch December 8, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants